package org.jeeasy.system.modules.test.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.jeeasy.common.core.annotation.dict.DictTranslation;
import org.jeeasy.common.core.base.SimpleCurdController;
import org.jeeasy.common.core.domain.model.QueryPageModel;
import org.jeeasy.common.core.domain.vo.R;
import org.jeeasy.system.modules.test.domain.SysTest;
import org.jeeasy.system.modules.test.domain.dto.SysTestDTO;
import org.jeeasy.system.modules.test.domain.vo.SysTestVO;
import org.jeeasy.system.modules.test.service.SysTestService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 测试单表 Controller
 *
 * @author wei.yang
 * @date 2025-01-23 21:43:30
 */
@RestController
@Tag(name = "测试单表")
@RequestMapping("/sys/test")
public class SysTestController extends SimpleCurdController<SysTestService, SysTest> {

    @GetMapping
    @DictTranslation
    @Operation(summary = "测试单表列表")
    public R<IPage<SysTestVO>> page(QueryPageModel queryPageModel) {
        return R.ok(SysTestVO.transfer(super.queryPage(queryPageModel), SysTestVO.class));
    }

    @GetMapping("/{id}")
    @DictTranslation
    @Operation(summary = "根据ID查找测试单表")
    public R<SysTestVO> info(@PathVariable("id") String id) {
        return R.ok(super.getById(id).transfer(SysTestVO.class));
    }

    @PostMapping
    @Operation(summary = "添加测试单表")
    public R<Void> add(@Validated @RequestBody SysTestDTO dto) {
        super.insert(dto.toDO());
        return R.ok();
    }

    @PutMapping
    @Operation(summary = "编辑测试单表")
    public R<Void> edit(@Validated @RequestBody SysTestDTO dto) {
        super.update(dto.toDO());
        return R.ok();
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "根据ID删除测试单表")
    public R<Void> remove(@PathVariable("id") String id) {
        super.deleteById(id);
        return R.ok();
    }

    @DeleteMapping("/batch")
    @Operation(summary = "批量删除测试单表")
    public R<Void> batchRemove(@RequestParam(name = "ids") String ids) {
        super.batchDelete(ids);
        return R.ok();
    }

}